﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NNBankerMultiple : MonoBehaviour {
    public UILabel timeLable;
    public GameObject NoBtn;
    public GameObject OneBtn;
    public GameObject TwoBtn;
    public GameObject ThreeBtn;
    public GameObject FourBtn;
    private int Multiple;
    public List<GameObject> Covers;
    private void Awake()
    {
        UIEventListener.Get(NoBtn).onClick = ButtonClick;
        UIEventListener.Get(OneBtn).onClick = ButtonClick;
        UIEventListener.Get(TwoBtn).onClick = ButtonClick;
        UIEventListener.Get(ThreeBtn).onClick = ButtonClick;
        UIEventListener.Get(FourBtn).onClick = ButtonClick;
    }

    public float timeCount = 6f;
    private void Update()
    {
        timeCount -= Time.deltaTime;

        if (timeCount > 0)
        {
            int i = (int)timeCount;
            timeLable.text = i.ToString();
        }
        else if (timeCount < 0)
        {
            Destroy(gameObject);
        }
    }

    /// <summary>
    /// 控制能点击的倍数 --最大倍数
    /// </summary>
    public void ShowCanClick(int maxBankerMmultiple) {
        for (int i = 0; i < maxBankerMmultiple;i++) {
            
            Covers[i].SetActive(false);
        }
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "NoBtn")
        {
            Multiple = 0;
        }
        else if (button.name == "OneBtn")
        {
            Multiple = 1;
        }
        else if (button.name == "TwoBtn")
        {
            Multiple = 2;
        }
        else if (button.name == "ThreeBtn")
        {
            Multiple = 3;
        }
        else if (button.name == "FourBtn")
        {
            Multiple = 4;
        }
        SendBankerMultipleRequest();
    }

    void SendBankerMultipleRequest() {
        NnBankerMultipleRequest lg = new Pb.NnBankerMultipleRequest {  Multiple = Multiple };
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendProtobuf1(lg, MsgId.NnBankerMultipleRequest);
    }
}
